<script setup lang="ts">


import {onMounted, ref} from "vue";
import {KnowledgeApi} from "@/api/cloud/knowledge.ts";
import {cloud} from "@/api/dto";
import type {DataTableColumns} from "naive-ui";
import {useI18n} from "vue-i18n";

const KnowledgeResult = ref<cloud.Knowledge[]>()
onMounted(() => {
    KnowledgeApi.KnowledgeSearch({
        pageInfo: {
            page: 1,
            pageSize: 20,
        },
        data: {
            ...cloud.DefaultValue.Knowledge,
        },
    }).then(resp => {
        console.log(resp)
        KnowledgeResult.value = resp.data.items
    })
})
let composer = useI18n();
const columns: DataTableColumns<cloud.Order> = [...[
    {
        type: "selection",
        multiple: true,
        disabled(row: cloud.Order) {
            return row.number == "Edward King 3"
        }
    },
    {title: composer.t("module.knowledge.title"), key: "title"},
    {title: composer.t("module.knowledge.category"), key: "category"},
    {title: composer.t("module.knowledge.language"), key: "language"},
    {title: composer.t("module.knowledge.show"), key: "show", resizable: true,},
]]
const rowKey = (row: cloud.Knowledge) => row.id
</script>

<template lang="pug">
div
    h1   {{ $t('menu.knowledge') }}
    n-data-table(:data="KnowledgeResult"
        size="small"
        :columns="columns"
        striped
        :bordered="false"
        :row-key="rowKey"
    )
</template>

<style scoped lang="scss">

</style>